<?php 
	class NotificationView
	{
		private $model;
		private $controller;
		function __construct($model,$controller)
		{
			$this->model=$model;
			$this->controller=$controller;
		}
		
		function comment_notification()
		{
			global $current_user;
			$counter=$this->model->get_counter($current_user->id,'comment');
			if($counter==0) 
				$active='deactive_buble';
			$view="<a  onclick='return false;'><div class='noti_Container' id='btn_comment'>
				    <img src='".plugins_url('source/comment-icon.png',__FILE__)."' class='icon' alt='profile' />
				    <div class='noti_bubble comment_counter ".$active."' id='comment_counter'>".$counter."</div>
					</div></a>
				<ul class='notification_menu' id='commented_list' style='color:white;visibility:visible;display:block'></ul>";
				return $view;
		}
		function like_notification()
		{
			global $current_user;
			$counter=$this->model->get_counter($current_user->id,'like');
			$active='';
			if($counter==0) 
				$active='deactive_buble';
			$view="<a  onclick='return false;'><div class='noti_Container' id='btn_like'>
				    <img src='".plugins_url('source/like-icon.png',__FILE__)."' class='icon' alt='profile' />
				    <div class='noti_bubble like_counter ".$active."' id='like_counter'>".$counter."</div></div>
				</a>
				<ul  class='notification_menu' id='liked_list' style='color:white;visibility:visible;display:block'></ul>

				";
				return $view;
		}
		function image_notification()
		{
			$view="<div class='noti_Container' id='btn_image'>
				    <img src='".plugins_url('source/camera-icon.png',__FILE__)."' class='icon' alt='profile' />
				    <div class='noti_bubble image_counter' id='image_counter'>3</div>
				</div>
				";
				return $view;
		}
		function view_liked_list()
		{
			global $current_user; //lay nguoi dung hien tai
			$upload_dir = wp_upload_dir(); 
			$user_id=$current_user->id;
			//$likes=$this->model->get_liked_list($user_id);

			$images = $this->model->get_new_notification_images($user_id,'like');//tra ve danh sach cac anh duoc thich van chua xem
			if(count($images)==0) {
			 echo 'Chưa có ảnh nào của bạn được thích'; 
			}
			?>
				
				<?php 
					foreach ($images as $image) {
						$image_id = $image->object_id;
						$notify_image=$this->model->get_image($image_id);
						$last_like=$this->model->get_last_actor($user_id,$image_id,'like');//lay nguoi cuoi cung da thich
						$like_counter=$this->model->get_all_counter($user_id,$image_id,'like')-1;//va so nguoi con lai da thich anh cua ban
				
				 ?>
					<li style='width:100%;padding:3px;'>
						<a>
							<div style='display:inline;top:0px;position:relative;float:left;width:260px'><b><?php echo $last_like->user_login;?> </b><?php if($like_counter>0) echo ' và '.$like_counter.' người khác'; ?>  đã thích ảnh của bạn </div>
							 <img id="notify_thumb" style='width:auto;height:50px;display:inline;position:relative;float:right' src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$notify_image->image_url; ?>">
						</a>
					</li>

				<?php } 
		}
		function view_commented_list()
		{
			global $current_user; //lay nguoi dung hien tai
			$upload_dir = wp_upload_dir(); 
			$user_id=$current_user->id;
			//$likes=$this->model->get_liked_list($user_id);

			$images = $this->model->get_new_notification_images($user_id,'comment');//tra ve danh sach cac anh duoc thich van chua xem
			if(count($images)==0) {
			 echo 'Không có bình luận nào cho ảnh của bạn'; 
			}
			?>
				
				<?php 
					foreach ($images as $image) {
						$image_id = $image->object_id;
						$notify_image=$this->model->get_image($image_id);
						$last_like=$this->model->get_last_actor($user_id,$image_id,'comment');//lay nguoi cuoi cung da thich
						$like_counter=$this->model->get_all_counter($user_id,$image_id,'comment')-1;//va so nguoi con lai da thich anh cua ban
				 ?>
					<li style='width:100%;padding:3px;'>
						<a>
							<div style='display:inline;top:0px;position:relative;float:left;width:260px'><b><?php echo $last_like->user_login;?> </b><?php if($like_counter>0) echo ' và '.$like_counter.' người khác'; ?>  đã bình luận trên ảnh của bạn </div>
							 <img id="notify_thumb" style='width:auto;height:50px;display:inline;position:relative;float:right' src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$notify_image->image_url; ?>">
						</a>
					</li>
				<?php } 
		}
		function chat_room()
		{
			?>

			<div class="chat_wrapper">
				<div class="message_box" id="msgbox">
			        <?php 
			            //echo file_get_contents("http://date-asia.com/log.txt");
			        ?>
			    </div>
				<div class="panel">
					<input type="text" name="message" id="message" placeholder="Thông điệp" maxlength="80" style="width:60%" />
					<button id="sendbtn">Gửi</button>
				</div>
			</div>
			<?php
		}
	}
 ?>